<template>
  <a-config-provider :locale="locale">
    <component :is="layout">
      <router-view />
    </component>
  </a-config-provider>
</template>

<script lang="ts" setup>
  import { computed } from 'vue';
  import enUS from '@arco-design/web-vue/es/locale/lang/en-us';
  import zhCN from '@arco-design/web-vue/es/locale/lang/zh-cn';
  import useLocale from '@/hooks/locale';
  import { useRoute } from 'vue-router';
  import DefaultLayout from '@/layout/default-layout.vue';

  const route = useRoute();
  // 计算属性：判断当前路由是否需要布局
  const layout = computed(() =>
    route.meta.requiresLayout ? DefaultLayout : 'div'
  );
  const { currentLocale } = useLocale();
  const locale = computed(() => {
    switch (currentLocale.value) {
      case 'zh-CN':
        return zhCN;
      case 'en-US':
        return enUS;
      default:
        return enUS;
    }
  });
</script>
